using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace ManagedKeySimulator
{
	public class Keyboard
	{
		[DllImport("KeySimulator.dll", SetLastError = true)]
		private static extern void SimulateKeyboard(Byte wKeyToPress, bool bPress, bool bRelease);

		public static void PressKey(Byte keyToPress)
		{
			SimulateKeyboard(keyToPress, true, true);
		}

		public static void PressKey(Char keyToPress)
		{
			PressKey((Byte)keyToPress);
		}

		public static void HoldKey(Byte keyToHold)
		{
			SimulateKeyboard(keyToHold, true, false);
		}

		public static void HoldKey(Char keyToHold)
		{
			HoldKey((Byte)keyToHold);
		}

		public static void ReleaseKey(Byte keyToRelease)
		{
			SimulateKeyboard(keyToRelease, false, true);
		}

		public static void ReleaseKey(Char keyToRelease)
		{
			ReleaseKey((Byte)keyToRelease);
		}
	}
}
